#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
#include <ctime>
#include <cstring>
#include <cstdlib>
using namespace std;

class mi_rand
{
    public:
        mi_rand (int start_pos, int end_pos) : a(start_pos), b(end_pos) 
        {
            if (a > b) swap(a,b);
            srand ((unsigned) time(NULL));
        }

        unsigned operator () () 
        {
            return rand() % (b-a+1) + a;
        }

    private:
        int a, b;
};

int& recursiveMinimum (vector<int>& array, int start, int end)
{
    static int *min = NULL;
    if (min == NULL) min = &array[start];
    if (start == end) 
    {
        int *rt = min;
        min = NULL;
        return *rt;
    }
    if (array[start] < *min) min = &array[start];
    return recursiveMinimum (array, start + 1, end);
}

int main()
{
    const int SIZE = 50;
    vector<int> array(SIZE);
    generate_n (array.begin(), SIZE, mi_rand(10, 200));
    
    copy (array.begin(), array.end(), 
          ostream_iterator<int> (cout, " "));
    cout << endl;

    cout << endl << recursiveMinimum (array, 0, SIZE - 1) << endl;

    return 0;
}

